﻿using System.Collections.Generic;
using System.Linq;

namespace OpenWaves.ActivityFeed.Web.Tests
{
    public class ExtendedUpdateDto : UpdateDto
    {
        public IEnumerable<TopicInfo> Topics { get; set; }
    }

    public class TopicInfo
    {
        public string TopicName { get; set; }
        public string TopicUrl { get; set; }
    }

    public class ExtendedUpdateDtoBuilder : UpdateDtoBuilderBase<ExtendedUpdateDto>
    {
        public ExtendedUpdateDtoBuilder() : base(ServiceLocator.Resolve<IUserProfileProvider>())
        {
        }

        public ExtendedUpdateDtoBuilder(IUserProfileProvider userProfileProvider) : base(userProfileProvider)
        {
        }

        protected override ExtendedUpdateDto CreateDto(Update update)
        {
            return new ExtendedUpdateDto();
        }

        protected override void  MapUpdateToDto(Update update, ExtendedUpdateDto dto)
        {
 	        base.MapUpdateToDto(update, dto);
            dto.Topics = update.Topics
                    .Where(t => t != Topic.FromUserId(update.PublishedBy))
                    .Select(t => new TopicInfo { TopicName = t.ToString(), TopicUrl = "http://google.com?q=" + t })
                    .ToList();
        }
    }
}